package com.screen.screendisplay.service.impl.ne;

import com.screen.screendisplay.entity.ne.NeProdoperPowerGs;
import com.screen.screendisplay.mapper.ne.NeProdoperPowerGsMapper;
import com.screen.screendisplay.service.ne.NeProdoperPowerGsService;
import com.screen.screendisplay.vo.ne.NePowerGenerationAnnualVO;
import com.screen.screendisplay.vo.ne.NePowerGenerationDailyVO;
import com.screen.screendisplay.vo.ne.NePowerGenerationMonthlyVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 新能源发电情况统计表 服务实现类
 * </p>
 *
 * @author xuesong
 * @since 2025-08-23
 */
@Service
public class NeProdoperPowerGsServiceImpl extends ServiceImpl<NeProdoperPowerGsMapper, NeProdoperPowerGs> implements NeProdoperPowerGsService {

    @Autowired
    private NeProdoperPowerGsMapper neProdoperPowerGsMapper;

    @Override
    public List<NePowerGenerationAnnualVO> getAnnualPowerGeneration(Integer year) {
        List<NeProdoperPowerGs> dataList = neProdoperPowerGsMapper.selectAnnualData(5);
        return dataList.stream().map(data -> {
            NePowerGenerationAnnualVO vo = new NePowerGenerationAnnualVO();
            vo.setYear(data.getYear());
            vo.setPlannedGeneration(data.getPlannedGeneration());
            vo.setActualGeneration(data.getActualGeneration());
            return vo;
        }).collect(Collectors.toList());
    }

    @Override
    public List<NePowerGenerationMonthlyVO> getMonthlyPowerGeneration(Integer year) {
        List<NeProdoperPowerGs> dataList = neProdoperPowerGsMapper.selectMonthlyData(6);
        return dataList.stream().map(data -> {
            NePowerGenerationMonthlyVO vo = new NePowerGenerationMonthlyVO();
            vo.setYear(data.getYear());
            vo.setMonth(data.getMonth());
            vo.setPlannedGeneration(data.getPlannedGeneration());
            vo.setActualGeneration(data.getActualGeneration());
            return vo;
        }).collect(Collectors.toList());
    }

    @Override
    public List<NePowerGenerationDailyVO> getDailyPowerGeneration(Integer year) {
        List<NeProdoperPowerGs> dataList = neProdoperPowerGsMapper.selectDailyData(7);
        return dataList.stream().map(data -> {
            NePowerGenerationDailyVO vo = new NePowerGenerationDailyVO();
            vo.setYear(data.getYear());
            vo.setMonth(data.getMonth());
            vo.setDay(data.getDay());
            vo.setPlannedGeneration(data.getPlannedGeneration());
            vo.setActualGeneration(data.getActualGeneration());
            return vo;
        }).collect(Collectors.toList());
    }
}
